# -*- coding: utf-8 -*-
###############################################################################
# Import Modules
###############################################################################
import sys
import unittest
from backtracking import backtracking
from galeshapley import galeshapley


class TdaTP1(unittest.TestCase):

    def getOutput(self, filename):
        outputFile = file(filename)
        return outputFile.read()

    def getGaleShapley(self, filename):
        gs = galeshapley.GaleShapley(filename)
        gs.match()
        return gs.toString()

    def getBacktracking(self, filename):
        b = backtracking.Backtracking(filename)
        b.match()
        return b.solution

    def testGaleShapleyInput1(self):
        result = self.getGaleShapley('input1.txt')
        expected = self.getOutput('output1.gs.txt')
        self.assertEqual(result, expected)

    def testGaleShapleyInput2(self):
        result = self.getGaleShapley('input2.txt')
        expected = self.getOutput('output2.gs.txt')
        self.assertEqual(result, expected)

    def testGaleShapleyInput3(self):
        result = self.getGaleShapley('input3.txt')
        expected = self.getOutput('output3.gs.txt')
        self.assertEqual(result, expected)

    def testBacktrackingInput1(self):
        result = self.getBacktracking('input1.txt')
        expected = self.getOutput('output1.bt.txt')
        self.assertEqual(result, expected)

    def testBacktrackingInput2(self):
        result = self.getBacktracking('input2.txt')
        expected = self.getOutput('output2.bt.txt')
        self.assertEqual(result, expected)

    def testBacktrackingInput3(self):
        result = self.getBacktracking('input3.txt')
        expected = self.getOutput('output3.bt.txt')
        self.assertEqual(result, expected)


if __name__ == '__main__':
    unittest.main()
